<?php
//   +----------------------------------------------------------------------
//   | Copyright (c) 2015-2035 http://www.hdphp.cn All rights reserved.
//   | Licensed ( http://www.hdphp.cn/licenses/ )
//   | Author: Jack <sophia2152@qq.com>
//   | 官方网址: http://www.hdphp.cn
//   | 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用。
//   | 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
//   +----------------------------------------------------------------------

use think\Response;
use think\facade\Route;
use think\facade\Config;

/**
 * 用户端路由配置
 */
Route::group('api', function () {

    // 前端测试
    Route::get('index', 'v1.TestController/index')->option(['real_name' => '前端测试']);
    

    Route::get('get_copyright', 'v1.PublicController/getCopyright'); // 获取版权

    /**
     * miss 路由
     */
    Route::miss(function () {
        if (app()->request->isOptions()) {
            $header = Config::get('cookie.header');
            $header['Access-Control-Allow-Origin'] = app()->request->header('origin');
            return Response::create('ok')->code(200)->header($header);
        } else
            return Response::create()->code(404);
    });

})->prefix('api.')
    ->middleware(\app\http\middleware\InstallMiddleware::class)
    ->middleware(\app\http\middleware\AllowOriginMiddleware::class)
    ->middleware(\app\http\middleware\StationOpenMiddleware::class);